using System.Collections.Generic;
using System.Threading.Tasks;

namespace Light
{
    /// <summary>
    ///     ����Skill�Ļ�ȡ
    /// </summary>
    public class SkillsManager : Singleton<SkillsManager>, ISingleton
    {
        public void Initialize()
        {
        }

        /// <summary>
        ///     ��ȡ���м���
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<AbstractItemSO> GetSkillsItemData()
        {
            List<AbstractItemSO> res = new();
            var skills = SkillsTables.Instance.GetData<SkillItemListSO, SkillItemSO>(ItemType.Skill);
            foreach (var data in SkillsTables.Instance.GetSkillsItemJsonData())
            {
                var tempData = skills.Find(item => item.id == data.id);
                if (tempData != null) res.Add(tempData);
            }

            return res;
        }

        /// <summary>
        ///     ��ȡSkillsJsonData
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<SkillsJsonData> GetSkillsJsonData()
        {
            return SkillsTables.Instance.GetSkillsItemJsonData();
        }

        public static async Task<IEnumerable<SkillItemSO>> GetSkillDataAsync()
        {
            List<SkillItemSO> res = new();
            var items = await SkillsTables.Instance.GetDataAsync<SkillItemListSO, SkillItemSO>(ItemType.Skill);
            foreach (var data in SkillsTables.Instance.GetSkillsItemJsonData())
            {
                var tempData = items.Find(item => item.id == data.id);
                if (tempData != null) res.Add(tempData);
            }

            return res;
        }
    }
}